package com.waiting.thread;

import java.util.LinkedList;
import java.util.List;

/**
 * @Description
 * @Author bjweitingting
 * @Date 2019/3/8
 **/
public class BinaryTreeInorderTraversal94 {
    public static void main(String[] args) {

    }

    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> result = new LinkedList<>();
        ite(root, result);
        return result;
    }

    public void ite(TreeNode root, List<Integer> result) {
        if (root == null) {
            return;
        }
        if (root.left != null) {
            ite(root.left, result);
        }
        result.add(root.val);
        if (root.right != null) {
            ite(root.right, result);
        }
    }
}

class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;

    TreeNode(int x) {
        val = x;
    }
}
